#ifndef ICON_H_
#define ICON_H_

#include <gtk/gtk.h>
#include <gtkmm.h>
#include <gtkmm/icontheme.h>

#include "widgets.h"

namespace gpyp {

class Application;

class IconManager : boost::noncopyable {
public:
#include "icons/icon_decl.h"

  static const char *const BUILTIN_ICON_LIST[];

  static GtkIconSize ICON_SIZE_16;
  static GtkIconSize ICON_SIZE_32;
  static GtkIconSize ICON_SIZE_48;

  static const char *SPECIAL_WEBBROWSER;
  static const char *SPECIAL_BBSBROWSER;

  static bool is_special_icon(const Glib::ustring &name);

private:
  static sigc::signal<void, const char *> _signal_special_icon_changed;
public:
  inline static sigc::signal<void, const char *>
  signal_special_icon_changed() {
    return _signal_special_icon_changed;
  }

private:
  static Glib::ustring                _icondir_user;
  static Glib::RefPtr<Gtk::IconTheme> _icontheme_user;

  static Glib::ustring _sa_webbrowser;
  static Glib::ustring _sa_bbsbrowser;

public:
  static void init(OptionContext &opts);

  static void add_icon_file(const Glib::ustring &file_path);
  static bool remove_icon_file(const Glib::ustring &name);

  inline static Glib::RefPtr<Gtk::IconTheme> get_icontheme_user() {
    return _icontheme_user;
  }

  static Glib::RefPtr<Gdk::Pixbuf>
  load_icon(const Glib::ustring &icon_name,
            int                  size,
            GtkIconSize          icon_size,
            Gtk::IconLookupFlags flags = (Gtk::IconLookupFlags)0);

  inline static Glib::RefPtr<Gdk::Pixbuf>
  load_icon(const Glib::ustring &icon_name,
            GtkIconSize          icon_size,
            Gtk::IconLookupFlags flags = (Gtk::IconLookupFlags)0) {
    gint width, height;
    gtk_icon_size_lookup(icon_size, &width, &height);
    return load_icon(icon_name, width, icon_size, flags);
  }
  inline static Glib::RefPtr<Gdk::Pixbuf>
  load_icon(const Gtk::StockID  &stock_id,
            GtkIconSize          icon_size,
            Gtk::IconLookupFlags flags = (Gtk::IconLookupFlags)0) {
    return load_icon(stock_id.get_string(), icon_size, flags);
  }

  static bool has_icon(const Glib::ustring &icon_name);

  static Glib::ArrayHandle<int>
  get_icon_sizes(const Glib::ustring &icon_name);

private:
  Application &app_;

  void webbrowser_on_changed();
  void bbsbrowser_on_changed();

public:
  IconManager(Application &app);
};

}/* namespace gpyp */

#endif /*ICON_H_*/
